package com.yizn.learn.springext.springmvcext;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * project : my-learn
 * <p> 1.自定义拦截器 spring mvc拦截器根spring拦截器相比，它里面能够获取HttpServletRequest和HttpServletResponse等web对象实例。 </p>
 *
 * @author yisl
 * @date 2023-01-13【星期五】
 **/
public class AuthInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String requestUrl = request.getRequestURI();
        if (checkAuth(requestUrl)) {
            return true;
        }
        return false;
    }
    private boolean checkAuth(String requestUrl) {
        System.out.println("===权限校验===");
        return true;
    }
}
